package com.ming.projecttest.ui;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;

import com.ming.projecttest.R;
import com.ming.projecttest.fragment.ExampleFragment;

public class FragmentTestActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fragment);

        addFragment();
    }

    private void addFragment(){
        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        ExampleFragment exampleFragment = new ExampleFragment();
        ft.add(R.id.content_layout, exampleFragment);
        // 提交
        ft.commit();
    }
}
